#ifndef TCPSUBCLIENT_H
#define TCPSUBCLIENT_H

#include <QAbstractSocket>
#include <QDebug>
#include <QFile>
#include <QFileInfo>
#include <QHostAddress>
#include <QMetaType>
#include <QString>
#include <QStandardPaths>
#include <QTcpSocket>
#include <QJsonObject>

class TCPSubClient : public QObject
{
    Q_OBJECT

public:
    explicit TCPSubClient(QObject *parent = nullptr);
    ~TCPSubClient();

signals:
    void newMessage(QString);

public:
    int connectToServer(QString strIP,int port);
    void disconnect();

    void sendMessage(QString str);
    void sendRawMessage(QString message);
    void sendAttachment(QString filePath);
    void discardSocket();

private slots:
    void readSocket();
    void displayError(QAbstractSocket::SocketError socketError);
    void displayMessage(const QString& str);


private:
    QTcpSocket* socket;
    QDataStream* socketStream;
};

#endif // TCPSUBCLIENT_H
